package com.javasearch.index;

import com.javasearch.index.build.ClassBuild;
import com.javasearch.utils.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DelIndex {
    private static final Logger logger = LoggerFactory.getLogger(DelIndex.class);
    public static void delIndex() {
        String CLASS = FileUtil.getTempDirectoryPath() + IndexEnum.CLASS.getIndexName();
        String ANNOTATION = FileUtil.getTempDirectoryPath() + IndexEnum.ANNOTATION.getIndexName();
        String METHOD = FileUtil.getTempDirectoryPath() + IndexEnum.METHOD.getIndexName();
        String FIELD = FileUtil.getTempDirectoryPath() + IndexEnum.FIELD.getIndexName();
        FileUtil.delFilesAll(CLASS,true);
        logger.info("删除类名缓存目录:{}",CLASS);
        FileUtil.delFilesAll(ANNOTATION,true);
        logger.info("删除注解缓存目录:{}",ANNOTATION);
        FileUtil.delFilesAll(METHOD,true);
        logger.info("删除方法缓存目录:{}",METHOD);
        FileUtil.delFilesAll(FIELD,true);
        logger.info("删除字段缓存目录:{}",FIELD);

        //删除源码包
        String SOURCES = FileUtil.getTempDirectoryPath() + IndexEnum.SOURCES.getIndexName();
        FileUtil.delFilesAll(SOURCES,true);
        logger.info("删除源码包缓存目录:{}",SOURCES);
        //删除java文件
        String JAVAPATH = FileUtil.getTempDirectoryPath() + IndexEnum.JAVAPATH.getIndexName();
        FileUtil.delFilesAll(JAVAPATH,true);
        logger.info("删除java文件缓存目录:{}",JAVAPATH);
    }
}
